package com.soft.service;

import java.util.List;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.Assert;

import com.soft.entity.Worker;

@SpringBootTest
public class WorkerServiceTest {
	@Autowired
	private WorkerService workerService;
	//@Test
	public void queryAllTest() {
		List<Worker> workerList = workerService.queryAll();
		Assert.notEmpty(workerList, "为空");
		Assert.isTrue(workerList.size()>0,"有值");
	}
	
	//@Test
	public void queryBySexTest() {
		List<Worker> workerList = workerService.queryBySex("人类");
		Assert.isTrue(workerList.size()==2,"结果错误");
	}
	
	//@Test
	public void insertOneTest() {
		int num =workerService.insertOne("其余成","男","87526");
		Assert.isTrue(num == 1,"错误");
	}
	
	//@Test
	public void deleteByIdTest() {
		int num =workerService. deleteById(3);
		Assert.isTrue(num == 1,"错误");
	}
	
	//@Test
	public void updateTest() {
		int num =workerService.update(1l,"小张","男","85269");
		Assert.isTrue(num == 1,"错误");
	}
	
	//@Test
	public void queryByWorkerLiveAddressTest() {
		List<Worker> workerList = workerService.queryByWorkerLiveAddress("东苑");
		Assert.isTrue(workerList.size()==1,"错误");
	}
	
	//@Test
	public void insertWorkerTest() {
		int num = workerService.insertWorker("落落","女","88888888","西苑");
		Assert.isTrue(num == 1,"增加错误");
	}
	
	@Test
	public void updateWorkerTest() {
		int num = workerService.updateWorker("落落","女","878787","西苑");
		Assert.isTrue(num == 1,"更新错误");
	}
}